home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / dev / devSCSIHBA.c < prev    next >
C/C++ Source or Header  |  1991-08-11  |  4KB  |  136 lines

  1. /* 
  2.  * devSCSIHBA.c --
  3.  *
  4.  *      The standard Open, Read, Write, IOControl, and Close operations
  5.  *      for  SCSI Host Bus Adaptor (HBA) device drivers. This driver permits
  6.  *    user level programs to send arbitrary SCSI commands to SCSI
  7.  *    devices.
  8.  *
  9.  * Copyright 1986 Regents of the University of California
  10.  *
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  *
  19.  */
  20.  
  21. #ifndef lint
  22. static char rcsid[] = "$Header: /sprite/src/kernel/dev/RCS/devSCSIHBA.c,v 9.0 89/09/12 14:58:23 douglis Stable $ SPRITE (Berkeley)";
  23. #endif not lint
  24.  
  25.  
  26. #include "sprite.h"
  27. #include "fs.h"
  28. #include "dev.h"
  29. #include "devInt.h"
  30. #include "scsi.h"
  31. #include "scsiDevice.h"
  32. #include "dev/scsi.h"
  33. #include "scsiHBADevice.h"
  34. #include "stdlib.h"
  35.  
  36. #include "dbg.h"
  37.  
  38.  
  39.  
  40. /*
  41.  *----------------------------------------------------------------------
  42.  *
  43.  * DevSCSIDeviceOpen --
  44.  *
  45.  *    Open a SCSI device as a file.  This routine attaches the 
  46.  *    device.
  47.  *
  48.  * Results:
  49.  *    SUCCESS if the device is attached.
  50.  *
  51.  * Side effects:
  52.  *    None.
  53.  *
  54.  *----------------------------------------------------------------------
  55.  */
  56. /* ARGSUSED */
  57. ReturnStatus
  58. DevSCSIDeviceOpen(devicePtr, useFlags, token, flagsPtr)
  59.     Fs_Device *devicePtr;    /* Device info, unit number etc. */
  60.     int useFlags;        /* Flags from the stream being opened */
  61.     Fs_NotifyToken token;    /* Call-back token for input, unused here */
  62.     int     *flagsPtr;        /* OUT: Device open flags. */
  63. {
  64.     ScsiDevice *devPtr;
  65.  
  66.     /*
  67.      * Ask the HBA to set up the path to the device with FIFO ordering
  68.      * of requests.
  69.      */
  70.     devPtr = DevScsiAttachDevice(devicePtr, DEV_QUEUE_FIFO_INSERT);
  71.     if (devPtr == (ScsiDevice *) NIL) {
  72.     return DEV_NO_DEVICE;
  73.     }
  74.     devicePtr->data = (ClientData) devPtr;
  75.     return(SUCCESS);
  76. }
  77.  
  78. /*
  79.  *----------------------------------------------------------------------
  80.  *
  81.  * DevSCSIDeviceIOControl --
  82.  *
  83.  *    Do a special operation on a raw SCSI Device.
  84.  *
  85.  * Results:
  86.  *    None.
  87.  *
  88.  * Side effects:
  89.  *    None.
  90.  *
  91.  *----------------------------------------------------------------------
  92.  */
  93. /*ARGSUSED*/
  94. ReturnStatus
  95. DevSCSIDeviceIOControl(devicePtr, ioctlPtr, replyPtr)
  96.     Fs_Device *devicePtr;
  97.     Fs_IOCParam *ioctlPtr;    /* Standard I/O Control parameter block */
  98.     Fs_IOReply *replyPtr;    /* Size of outBuffer and returned signal */
  99. {
  100.     ScsiDevice *devPtr;
  101.     devPtr = (ScsiDevice *)(devicePtr->data);
  102.     return DevScsiIOControl(devPtr, ioctlPtr, replyPtr);
  103. }
  104.  
  105. /*
  106.  *----------------------------------------------------------------------
  107.  *
  108.  * Dev_SCSITapeClose --
  109.  *
  110.  *    Close a raw SCSI device. 
  111.  *
  112.  * Results
  113.  *    SUCCESS
  114.  *
  115.  * Side effects:
  116.  *    None.
  117.  *
  118.  *----------------------------------------------------------------------
  119.  */
  120. /*ARGSUSED*/
  121. ReturnStatus
  122. DevSCSIDeviceClose(devicePtr, useFlags, openCount, writerCount)
  123.     Fs_Device    *devicePtr;
  124.     int        useFlags;    /* FS_READ | FS_WRITE */
  125.     int        openCount;    /* Number of times device open. */
  126.     int        writerCount;    /* Number of times device open for writing. */
  127. {
  128.     ScsiDevice *devPtr;
  129.     ReturnStatus status = SUCCESS;
  130.  
  131.     devPtr = (ScsiDevice *)(devicePtr->data);
  132.     (void) DevScsiReleaseDevice(devPtr);
  133.     devicePtr->data = (ClientData) NIL;
  134.     return(status);
  135. }
  136.